{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Imports\n",
    "\n",
    "Import all the modules and functionalities we need."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "\n",
    "# Import standard libraries.\n",
    "import os\n",
    "\n",
    "# Import third party libraries.\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "from statsmodels.stats.multitest import multipletests\n",
    "\n",
    "# Import custom libraries/scripts.\n",
    "import annotations\n",
    "import helpers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Loading data\n",
    "\n",
    "Fetch all our relevant data for the current analysis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set working contants.\n",
    "EXPERIMENTS_PATH = r'D:\\Miguel\\PhD\\Results\\Competition\\DL\\small_arenas\\Or67d\\crossed_with_white_minus\\processed'\n",
    "FPS = 60\n",
    "N_MINUTES = 5\n",
    "N_FRAMES = N_MINUTES * 60 * FPS # First five minutes of copulation.\n",
    "INK = 'black'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set figure configurations.\n",
    "sns.set(\n",
    "        context='paper',\n",
    "        style='ticks',\n",
    "        font='sans-serif',\n",
    "        font_scale=1.0, \n",
    "        rc={\n",
    "            'axes.axisbelow': True,\n",
    "            'axes.edgecolor': INK,\n",
    "            'axes.facecolor': 'white' if INK=='black' else 'black',\n",
    "            'axes.grid': False,\n",
    "            'axes.labelcolor': INK,\n",
    "            'axes.labelsize': 13.0,\n",
    "            'axes.labelweight': 'normal',\n",
    "            'axes.linewidth': 1.0,\n",
    "            'axes.spines.left': True,\n",
    "            'axes.spines.bottom': True,\n",
    "            'axes.spines.top': False,\n",
    "            'axes.spines.right': False,\n",
    "            'axes.titlepad': 15.0,\n",
    "            'axes.titlesize': 20.0,\n",
    "            'axes.titleweight': 'bold',\n",
    "            'figure.facecolor': 'white' if INK=='black' else 'black',\n",
    "            'figure.figsize': [4.0, 4.0],\n",
    "            'figure.titlesize': 30.0,\n",
    "            'figure.titleweight': 'bold',\n",
    "            'font.family': ['sans-serif'],\n",
    "            'font.sans-serif': ['Arial'],\n",
    "            'legend.frameon': False,\n",
    "            'legend.fontsize': 11.0,\n",
    "            'lines.color': INK,\n",
    "            'lines.linewidth': 1.0,\n",
    "            'patch.edgecolor': INK,\n",
    "            'savefig.dpi': 300,\n",
    "            'savefig.format': 'png',\n",
    "            'savefig.bbox': 'tight',\n",
    "            'savefig.transparent': True,\n",
    "            'text.color': INK,\n",
    "            'text.usetex': False,\n",
    "            'xtick.color': INK,\n",
    "            'xtick.direction': 'out',\n",
    "            'xtick.labelsize': 12.0,\n",
    "            'xtick.major.pad': 5.0,\n",
    "            'xtick.major.size': 0.0,\n",
    "            'xtick.major.width': 1.0,\n",
    "            'xtick.minor.size': 0.0,\n",
    "            'xtick.minor.width': 0.4,\n",
    "            'ytick.color': INK,\n",
    "            'ytick.direction': 'out',\n",
    "            'ytick.labelsize': 12.0,\n",
    "            'ytick.major.pad': 5.0,\n",
    "            'ytick.major.size': 3.0,\n",
    "            'ytick.major.width': 1.0,\n",
    "            'ytick.minor.size': 0.0,\n",
    "            'ytick.minor.width': 0.4\n",
    "           }\n",
    "       )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Folder already exists, skipping.\n"
     ]
    }
   ],
   "source": [
    "# Prepare the Figures folder to save our graphs in.\n",
    "savepath = os.path.join(r'C:\\Users\\Miguel\\Desktop\\paper_data', 'paper_figures', 'figureS3')\n",
    "try:\n",
    "    os.makedirs(savepath)\n",
    "    print(\"New folder created.\")\n",
    "except FileExistsError:\n",
    "    print(\"Folder already exists, skipping.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Paths to conditions:\n",
      " ['D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control', 'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test', 'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control']\n"
     ]
    }
   ],
   "source": [
    "# Set the conditions to analyze.\n",
    "condition_order = ['gal4_control', 'uas_control', 'test']\n",
    "conditions = [item.path for item in os.scandir(EXPERIMENTS_PATH) if item.name in condition_order]\n",
    "print('Paths to conditions:\\n', conditions)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\t\n",
      " gal4_control\n",
      "\t\n",
      " test\n",
      "Copulation too short: video_2021-02-15T11_07_47_arena5.csv\n",
      "Copulation too short: video_2021-02-19T11_33_52_arena10.csv\n",
      "\t\n",
      " uas_control\n",
      "Copulation too short: video_2021-02-15T10_18_59_arena3.csv\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'gal4_control': ['D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T10_18_59_arena1.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T10_18_59_arena10.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T10_18_59_arena16.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T10_18_59_arena6.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T10_18_59_arena8.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T11_07_47_arena11.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T11_07_47_arena3.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T11_07_47_arena4.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T11_07_47_arena6.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T11_07_47_arena7.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-16T12_26_11_arena11.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-16T12_26_11_arena13.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-16T12_26_11_arena14.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-16T12_26_11_arena3.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-16T12_26_11_arena9.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T10_22_44_arena1.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T10_22_44_arena10.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T10_22_44_arena12.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T10_22_44_arena15.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T10_22_44_arena7.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T10_22_44_arena8.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T11_13_09_arena1.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T11_13_09_arena11.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T11_13_09_arena4.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T11_13_09_arena6.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T11_23_50_arena1.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T11_23_50_arena15.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T11_23_50_arena2.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T11_23_50_arena7.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T11_23_50_arena9.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T12_15_02_arena1.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T12_15_02_arena11.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T12_15_02_arena13.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T12_15_02_arena16.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T12_15_02_arena4.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T12_15_02_arena6.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-19T10_46_46_arena7.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-19T11_33_52_arena14.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-19T11_33_52_arena8.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-19T11_33_52_arena9.csv'],\n",
       " 'uas_control': ['D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-15T10_18_59_arena14.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-15T10_18_59_arena7.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-15T11_07_47_arena13.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-15T11_07_47_arena14.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-15T11_07_47_arena8.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-16T12_26_11_arena12.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-16T12_26_11_arena7.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-16T12_26_11_arena8.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-17T10_22_44_arena6.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-17T10_22_44_arena9.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-17T11_13_09_arena14.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-17T11_13_09_arena9.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-18T11_23_50_arena13.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-18T11_23_50_arena4.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-18T11_23_50_arena6.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-18T12_15_02_arena2.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-19T10_46_46_arena12.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-19T10_46_46_arena15.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-19T11_33_52_arena11.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-19T11_33_52_arena3.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-19T11_33_52_arena7.csv'],\n",
       " 'test': ['D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T10_18_59_arena11.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T10_18_59_arena15.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T10_18_59_arena4.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T10_18_59_arena5.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T10_18_59_arena9.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T11_07_47_arena10.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T11_07_47_arena15.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T11_07_47_arena16.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T11_07_47_arena2.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T11_07_47_arena9.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-16T12_26_11_arena1.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-16T12_26_11_arena16.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-16T12_26_11_arena2.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-16T12_26_11_arena5.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-17T10_22_44_arena11.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-17T10_22_44_arena2.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-17T11_13_09_arena10.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-17T11_13_09_arena13.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-17T11_13_09_arena15.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-17T11_13_09_arena3.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-17T11_13_09_arena5.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-18T12_15_02_arena10.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena10.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena11.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena13.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena14.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena2.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena3.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena6.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena9.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T11_33_52_arena5.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T11_33_52_arena6.csv']}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Load all usable experiments for each condition.\n",
    "experiments = {condition: [] for condition in condition_order}\n",
    "\n",
    "for condition_path in conditions:\n",
    "    \n",
    "    condition = os.path.basename(condition_path)\n",
    "    print('\\t\\n', condition)\n",
    "    \n",
    "    for item in os.scandir(condition_path):\n",
    "        if item.name.endswith('.csv'):\n",
    "            \n",
    "            annotation_video = annotations.read(item.path)\n",
    "\n",
    "            try:\n",
    "                copulation = annotation_video[0].events[0]\n",
    "\n",
    "                # Filter out videos where copulation is interrupted.\n",
    "                copulation_end = copulation.time_interval[1]\n",
    "                if copulation_end==N_FRAMES:\n",
    "                    if copulatio.duration < 5 * 60 * FPS:\n",
    "                        print('Copulation interrupted:', item.name)\n",
    "                        continue\n",
    "\n",
    "                # Filter out videos where copulation lasts less than 8 minutes.\n",
    "                copulation_duration = copulation.duration\n",
    "                if copulation_duration <= 8 * 60 * FPS:\n",
    "                    print('Copulation too short:', item.name)\n",
    "                    continue\n",
    "            \n",
    "            except IndexError:\n",
    "                continue\n",
    "            \n",
    "            experiments[condition].append(item.path)\n",
    "\n",
    "experiments"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Aggression Analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 0 \n",
      "Experiment: video_2021-02-15T10_18_59_arena1.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 1 \n",
      "Experiment: video_2021-02-15T10_18_59_arena10.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 2 \n",
      "Experiment: video_2021-02-15T10_18_59_arena16.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 3 \n",
      "Experiment: video_2021-02-15T10_18_59_arena6.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 4 \n",
      "Experiment: video_2021-02-15T10_18_59_arena8.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 5 \n",
      "Experiment: video_2021-02-15T11_07_47_arena11.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 6 \n",
      "Experiment: video_2021-02-15T11_07_47_arena3.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 7 \n",
      "Experiment: video_2021-02-15T11_07_47_arena4.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 8 \n",
      "Experiment: video_2021-02-15T11_07_47_arena6.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 9 \n",
      "Experiment: video_2021-02-15T11_07_47_arena7.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 10 \n",
      "Experiment: video_2021-02-16T12_26_11_arena11.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 11 \n",
      "Experiment: video_2021-02-16T12_26_11_arena13.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 12 \n",
      "Experiment: video_2021-02-16T12_26_11_arena14.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 13 \n",
      "Experiment: video_2021-02-16T12_26_11_arena3.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 14 \n",
      "Experiment: video_2021-02-16T12_26_11_arena9.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 15 \n",
      "Experiment: video_2021-02-17T10_22_44_arena1.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 16 \n",
      "Experiment: video_2021-02-17T10_22_44_arena10.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 17 \n",
      "Experiment: video_2021-02-17T10_22_44_arena12.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 18 \n",
      "Experiment: video_2021-02-17T10_22_44_arena15.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 19 \n",
      "Experiment: video_2021-02-17T10_22_44_arena7.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 20 \n",
      "Experiment: video_2021-02-17T10_22_44_arena8.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 21 \n",
      "Experiment: video_2021-02-17T11_13_09_arena1.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 22 \n",
      "Experiment: video_2021-02-17T11_13_09_arena11.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 23 \n",
      "Experiment: video_2021-02-17T11_13_09_arena4.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 24 \n",
      "Experiment: video_2021-02-17T11_13_09_arena6.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 25 \n",
      "Experiment: video_2021-02-18T11_23_50_arena1.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 26 \n",
      "Experiment: video_2021-02-18T11_23_50_arena15.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 27 \n",
      "Experiment: video_2021-02-18T11_23_50_arena2.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 28 \n",
      "Experiment: video_2021-02-18T11_23_50_arena7.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 29 \n",
      "Experiment: video_2021-02-18T11_23_50_arena9.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 30 \n",
      "Experiment: video_2021-02-18T12_15_02_arena1.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 31 \n",
      "Experiment: video_2021-02-18T12_15_02_arena11.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 32 \n",
      "Experiment: video_2021-02-18T12_15_02_arena13.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 33 \n",
      "Experiment: video_2021-02-18T12_15_02_arena16.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 34 \n",
      "Experiment: video_2021-02-18T12_15_02_arena4.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 35 \n",
      "Experiment: video_2021-02-18T12_15_02_arena6.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 36 \n",
      "Experiment: video_2021-02-19T10_46_46_arena7.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 37 \n",
      "Experiment: video_2021-02-19T11_33_52_arena14.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 38 \n",
      "Experiment: video_2021-02-19T11_33_52_arena8.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 39 \n",
      "Experiment: video_2021-02-19T11_33_52_arena9.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 0 \n",
      "Experiment: video_2021-02-15T10_18_59_arena14.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 1 \n",
      "Experiment: video_2021-02-15T10_18_59_arena7.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 2 \n",
      "Experiment: video_2021-02-15T11_07_47_arena13.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 3 \n",
      "Experiment: video_2021-02-15T11_07_47_arena14.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 4 \n",
      "Experiment: video_2021-02-15T11_07_47_arena8.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 5 \n",
      "Experiment: video_2021-02-16T12_26_11_arena12.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 6 \n",
      "Experiment: video_2021-02-16T12_26_11_arena7.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 7 \n",
      "Experiment: video_2021-02-16T12_26_11_arena8.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 8 \n",
      "Experiment: video_2021-02-17T10_22_44_arena6.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 9 \n",
      "Experiment: video_2021-02-17T10_22_44_arena9.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 10 \n",
      "Experiment: video_2021-02-17T11_13_09_arena14.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 11 \n",
      "Experiment: video_2021-02-17T11_13_09_arena9.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 12 \n",
      "Experiment: video_2021-02-18T11_23_50_arena13.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 13 \n",
      "Experiment: video_2021-02-18T11_23_50_arena4.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 14 \n",
      "Experiment: video_2021-02-18T11_23_50_arena6.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 15 \n",
      "Experiment: video_2021-02-18T12_15_02_arena2.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 16 \n",
      "Experiment: video_2021-02-19T10_46_46_arena12.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 17 \n",
      "Experiment: video_2021-02-19T10_46_46_arena15.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 18 \n",
      "Experiment: video_2021-02-19T11_33_52_arena11.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 19 \n",
      "Experiment: video_2021-02-19T11_33_52_arena3.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 20 \n",
      "Experiment: video_2021-02-19T11_33_52_arena7.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 0 \n",
      "Experiment: video_2021-02-15T10_18_59_arena11.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 1 \n",
      "Experiment: video_2021-02-15T10_18_59_arena15.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 2 \n",
      "Experiment: video_2021-02-15T10_18_59_arena4.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 3 \n",
      "Experiment: video_2021-02-15T10_18_59_arena5.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 4 \n",
      "Experiment: video_2021-02-15T10_18_59_arena9.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 5 \n",
      "Experiment: video_2021-02-15T11_07_47_arena10.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 6 \n",
      "Experiment: video_2021-02-15T11_07_47_arena15.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 7 \n",
      "Experiment: video_2021-02-15T11_07_47_arena16.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 8 \n",
      "Experiment: video_2021-02-15T11_07_47_arena2.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 9 \n",
      "Experiment: video_2021-02-15T11_07_47_arena9.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 10 \n",
      "Experiment: video_2021-02-16T12_26_11_arena1.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 11 \n",
      "Experiment: video_2021-02-16T12_26_11_arena16.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 12 \n",
      "Experiment: video_2021-02-16T12_26_11_arena2.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 13 \n",
      "Experiment: video_2021-02-16T12_26_11_arena5.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 14 \n",
      "Experiment: video_2021-02-17T10_22_44_arena11.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 15 \n",
      "Experiment: video_2021-02-17T10_22_44_arena2.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 16 \n",
      "Experiment: video_2021-02-17T11_13_09_arena10.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 17 \n",
      "Experiment: video_2021-02-17T11_13_09_arena13.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 18 \n",
      "Experiment: video_2021-02-17T11_13_09_arena15.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 19 \n",
      "Experiment: video_2021-02-17T11_13_09_arena3.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 20 \n",
      "Experiment: video_2021-02-17T11_13_09_arena5.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 21 \n",
      "Experiment: video_2021-02-18T12_15_02_arena10.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 22 \n",
      "Experiment: video_2021-02-19T10_46_46_arena10.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 23 \n",
      "Experiment: video_2021-02-19T10_46_46_arena11.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 24 \n",
      "Experiment: video_2021-02-19T10_46_46_arena13.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 25 \n",
      "Experiment: video_2021-02-19T10_46_46_arena14.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 26 \n",
      "Experiment: video_2021-02-19T10_46_46_arena2.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 27 \n",
      "Experiment: video_2021-02-19T10_46_46_arena3.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 28 \n",
      "Experiment: video_2021-02-19T10_46_46_arena6.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 29 \n",
      "Experiment: video_2021-02-19T10_46_46_arena9.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 30 \n",
      "Experiment: video_2021-02-19T11_33_52_arena5.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 31 \n",
      "Experiment: video_2021-02-19T11_33_52_arena6.csv \n",
      "Condition: test \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>has_aggression</th>\n",
       "      <th>aggression_latency</th>\n",
       "      <th>aggression_latency_mins</th>\n",
       "      <th>nframes</th>\n",
       "      <th>nbouts</th>\n",
       "      <th>ratio_frames</th>\n",
       "      <th>ratio_bouts</th>\n",
       "      <th>condition</th>\n",
       "      <th>experiment</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>True</td>\n",
       "      <td>2601</td>\n",
       "      <td>0.722500</td>\n",
       "      <td>151</td>\n",
       "      <td>6</td>\n",
       "      <td>0.008389</td>\n",
       "      <td>1.2</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena1.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>True</td>\n",
       "      <td>2018</td>\n",
       "      <td>0.560556</td>\n",
       "      <td>101</td>\n",
       "      <td>4</td>\n",
       "      <td>0.005611</td>\n",
       "      <td>0.8</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena10.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>True</td>\n",
       "      <td>527</td>\n",
       "      <td>0.146389</td>\n",
       "      <td>281</td>\n",
       "      <td>12</td>\n",
       "      <td>0.015611</td>\n",
       "      <td>2.4</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena16.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>True</td>\n",
       "      <td>2511</td>\n",
       "      <td>0.697500</td>\n",
       "      <td>278</td>\n",
       "      <td>7</td>\n",
       "      <td>0.015444</td>\n",
       "      <td>1.4</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena6.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>True</td>\n",
       "      <td>3750</td>\n",
       "      <td>1.041667</td>\n",
       "      <td>178</td>\n",
       "      <td>5</td>\n",
       "      <td>0.009889</td>\n",
       "      <td>1.0</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena8.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>True</td>\n",
       "      <td>2065</td>\n",
       "      <td>0.573611</td>\n",
       "      <td>146</td>\n",
       "      <td>6</td>\n",
       "      <td>0.008111</td>\n",
       "      <td>1.2</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T10_46_46_arena3.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>True</td>\n",
       "      <td>5080</td>\n",
       "      <td>1.411111</td>\n",
       "      <td>559</td>\n",
       "      <td>12</td>\n",
       "      <td>0.031056</td>\n",
       "      <td>2.4</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T10_46_46_arena6.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>True</td>\n",
       "      <td>7954</td>\n",
       "      <td>2.209444</td>\n",
       "      <td>40</td>\n",
       "      <td>6</td>\n",
       "      <td>0.002222</td>\n",
       "      <td>1.2</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T10_46_46_arena9.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>True</td>\n",
       "      <td>2460</td>\n",
       "      <td>0.683333</td>\n",
       "      <td>197</td>\n",
       "      <td>9</td>\n",
       "      <td>0.010944</td>\n",
       "      <td>1.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T11_33_52_arena5.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>True</td>\n",
       "      <td>1109</td>\n",
       "      <td>0.308056</td>\n",
       "      <td>251</td>\n",
       "      <td>9</td>\n",
       "      <td>0.013944</td>\n",
       "      <td>1.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T11_33_52_arena6.csv</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    has_aggression  aggression_latency  aggression_latency_mins  nframes  \\\n",
       "0             True                2601                 0.722500      151   \n",
       "1             True                2018                 0.560556      101   \n",
       "2             True                 527                 0.146389      281   \n",
       "3             True                2511                 0.697500      278   \n",
       "4             True                3750                 1.041667      178   \n",
       "..             ...                 ...                      ...      ...   \n",
       "88            True                2065                 0.573611      146   \n",
       "89            True                5080                 1.411111      559   \n",
       "90            True                7954                 2.209444       40   \n",
       "91            True                2460                 0.683333      197   \n",
       "92            True                1109                 0.308056      251   \n",
       "\n",
       "    nbouts  ratio_frames  ratio_bouts     condition  \\\n",
       "0        6      0.008389          1.2  gal4_control   \n",
       "1        4      0.005611          0.8  gal4_control   \n",
       "2       12      0.015611          2.4  gal4_control   \n",
       "3        7      0.015444          1.4  gal4_control   \n",
       "4        5      0.009889          1.0  gal4_control   \n",
       "..     ...           ...          ...           ...   \n",
       "88       6      0.008111          1.2          test   \n",
       "89      12      0.031056          2.4          test   \n",
       "90       6      0.002222          1.2          test   \n",
       "91       9      0.010944          1.8          test   \n",
       "92       9      0.013944          1.8          test   \n",
       "\n",
       "                               experiment  \n",
       "0    video_2021-02-15T10_18_59_arena1.csv  \n",
       "1   video_2021-02-15T10_18_59_arena10.csv  \n",
       "2   video_2021-02-15T10_18_59_arena16.csv  \n",
       "3    video_2021-02-15T10_18_59_arena6.csv  \n",
       "4    video_2021-02-15T10_18_59_arena8.csv  \n",
       "..                                    ...  \n",
       "88   video_2021-02-19T10_46_46_arena3.csv  \n",
       "89   video_2021-02-19T10_46_46_arena6.csv  \n",
       "90   video_2021-02-19T10_46_46_arena9.csv  \n",
       "91   video_2021-02-19T11_33_52_arena5.csv  \n",
       "92   video_2021-02-19T11_33_52_arena6.csv  \n",
       "\n",
       "[93 rows x 9 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "aggression_df = pd.DataFrame()\n",
    "for condition in condition_order:\n",
    "    for h, experiment_path in enumerate(experiments[condition]):\n",
    "\n",
    "        experiment = os.path.basename(experiment_path)\n",
    "        \n",
    "        print('Iteration:', h, '\\nExperiment:', experiment, '\\nCondition:', condition, '\\n')\n",
    "        \n",
    "        # Exclude experiments without copulation (since aggression is only observed during copulation).\n",
    "        annotation_video = annotations.read(experiment_path)\n",
    "        try:\n",
    "            copulation = annotation_video[0].events[0]\n",
    "        except IndexError:\n",
    "            continue\n",
    "        \n",
    "        aggression_events = list(filter(lambda event: event.time < (copulation.time + N_FRAMES), annotation_video[1].events)) # Consider aggression only during the first 5 minutes of copulation.\n",
    "        n_events = len(aggression_events)\n",
    "\n",
    "        # In case there is aggression, do the necessary calculations.\n",
    "        if n_events > 0:\n",
    "            aggression_latency =  aggression_events[0].time - copulation.time\n",
    "            aggression_latency_mins = aggression_latency / (60 * FPS)\n",
    "            ratio_frames = sum([aggression.duration for aggression in aggression_events]) / N_FRAMES\n",
    "            ratio_bouts = n_events / N_MINUTES\n",
    "\n",
    "            aggression_data = pd.DataFrame({'has_aggression': True,\n",
    "                                            'aggression_latency': aggression_latency,\n",
    "                                            'aggression_latency_mins': aggression_latency_mins,\n",
    "                                            'nframes': sum([aggression.duration for aggression in aggression_events]),\n",
    "                                            'nbouts': n_events,\n",
    "                                            'ratio_frames': ratio_frames,\n",
    "                                            'ratio_bouts': ratio_bouts,\n",
    "                                            'condition': condition,\n",
    "                                            'experiment': experiment},\n",
    "                                            index=[h],\n",
    "                                           )\n",
    "\n",
    "        # If not, preset our dictionary with default values.\n",
    "        else:\n",
    "            aggression_data = pd.DataFrame({'has_aggression': False,\n",
    "                                            'aggression_latency': np.nan,\n",
    "                                            'aggression_latency_mins': np.nan,\n",
    "                                            'nframes': 0,\n",
    "                                            'nbouts': 0,\n",
    "                                            'ratio_frames': 0, \n",
    "                                            'ratio_bouts': 0,\n",
    "                                            'condition': condition,\n",
    "                                            'experiment': experiment},\n",
    "                                            index=[h],\n",
    "                                           )\n",
    "        \n",
    "        # Concatenate all data together.\n",
    "        aggression_df = pd.concat([aggression_df, aggression_data], ignore_index=True)\n",
    "\n",
    "aggression_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Outlier Detection"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\t gal4_control \n",
      "\n",
      "[8, 35]\n",
      "Number data points considered outliers: 2\n",
      "Percent data points considered outliers: 5.0 %\n",
      "\n",
      "\t uas_control \n",
      "\n",
      "[]\n",
      "Number data points considered outliers: 0\n",
      "Percent data points considered outliers: 0.0 %\n",
      "\n",
      "\t test \n",
      "\n",
      "[]\n",
      "Number data points considered outliers: 0\n",
      "Percent data points considered outliers: 0.0 %\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>has_aggression</th>\n",
       "      <th>aggression_latency</th>\n",
       "      <th>aggression_latency_mins</th>\n",
       "      <th>nframes</th>\n",
       "      <th>nbouts</th>\n",
       "      <th>ratio_frames</th>\n",
       "      <th>ratio_bouts</th>\n",
       "      <th>condition</th>\n",
       "      <th>experiment</th>\n",
       "      <th>author</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>True</td>\n",
       "      <td>2601</td>\n",
       "      <td>0.722500</td>\n",
       "      <td>151</td>\n",
       "      <td>6</td>\n",
       "      <td>0.008389</td>\n",
       "      <td>1.2</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena1.csv</td>\n",
       "      <td>Miguel</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>True</td>\n",
       "      <td>2018</td>\n",
       "      <td>0.560556</td>\n",
       "      <td>101</td>\n",
       "      <td>4</td>\n",
       "      <td>0.005611</td>\n",
       "      <td>0.8</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena10.csv</td>\n",
       "      <td>Miguel</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>True</td>\n",
       "      <td>527</td>\n",
       "      <td>0.146389</td>\n",
       "      <td>281</td>\n",
       "      <td>12</td>\n",
       "      <td>0.015611</td>\n",
       "      <td>2.4</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena16.csv</td>\n",
       "      <td>Miguel</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>True</td>\n",
       "      <td>2511</td>\n",
       "      <td>0.697500</td>\n",
       "      <td>278</td>\n",
       "      <td>7</td>\n",
       "      <td>0.015444</td>\n",
       "      <td>1.4</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena6.csv</td>\n",
       "      <td>Miguel</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>True</td>\n",
       "      <td>3750</td>\n",
       "      <td>1.041667</td>\n",
       "      <td>178</td>\n",
       "      <td>5</td>\n",
       "      <td>0.009889</td>\n",
       "      <td>1.0</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena8.csv</td>\n",
       "      <td>Miguel</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>True</td>\n",
       "      <td>2065</td>\n",
       "      <td>0.573611</td>\n",
       "      <td>146</td>\n",
       "      <td>6</td>\n",
       "      <td>0.008111</td>\n",
       "      <td>1.2</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T10_46_46_arena3.csv</td>\n",
       "      <td>Sophie</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>True</td>\n",
       "      <td>5080</td>\n",
       "      <td>1.411111</td>\n",
       "      <td>559</td>\n",
       "      <td>12</td>\n",
       "      <td>0.031056</td>\n",
       "      <td>2.4</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T10_46_46_arena6.csv</td>\n",
       "      <td>Sophie</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>True</td>\n",
       "      <td>7954</td>\n",
       "      <td>2.209444</td>\n",
       "      <td>40</td>\n",
       "      <td>6</td>\n",
       "      <td>0.002222</td>\n",
       "      <td>1.2</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T10_46_46_arena9.csv</td>\n",
       "      <td>Sophie</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>True</td>\n",
       "      <td>2460</td>\n",
       "      <td>0.683333</td>\n",
       "      <td>197</td>\n",
       "      <td>9</td>\n",
       "      <td>0.010944</td>\n",
       "      <td>1.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T11_33_52_arena5.csv</td>\n",
       "      <td>Sophie</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>True</td>\n",
       "      <td>1109</td>\n",
       "      <td>0.308056</td>\n",
       "      <td>251</td>\n",
       "      <td>9</td>\n",
       "      <td>0.013944</td>\n",
       "      <td>1.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T11_33_52_arena6.csv</td>\n",
       "      <td>Sophie</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>91 rows × 10 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    has_aggression  aggression_latency  aggression_latency_mins  nframes  \\\n",
       "0             True                2601                 0.722500      151   \n",
       "1             True                2018                 0.560556      101   \n",
       "2             True                 527                 0.146389      281   \n",
       "3             True                2511                 0.697500      278   \n",
       "4             True                3750                 1.041667      178   \n",
       "..             ...                 ...                      ...      ...   \n",
       "88            True                2065                 0.573611      146   \n",
       "89            True                5080                 1.411111      559   \n",
       "90            True                7954                 2.209444       40   \n",
       "91            True                2460                 0.683333      197   \n",
       "92            True                1109                 0.308056      251   \n",
       "\n",
       "    nbouts  ratio_frames  ratio_bouts     condition  \\\n",
       "0        6      0.008389          1.2  gal4_control   \n",
       "1        4      0.005611          0.8  gal4_control   \n",
       "2       12      0.015611          2.4  gal4_control   \n",
       "3        7      0.015444          1.4  gal4_control   \n",
       "4        5      0.009889          1.0  gal4_control   \n",
       "..     ...           ...          ...           ...   \n",
       "88       6      0.008111          1.2          test   \n",
       "89      12      0.031056          2.4          test   \n",
       "90       6      0.002222          1.2          test   \n",
       "91       9      0.010944          1.8          test   \n",
       "92       9      0.013944          1.8          test   \n",
       "\n",
       "                               experiment  author  \n",
       "0    video_2021-02-15T10_18_59_arena1.csv  Miguel  \n",
       "1   video_2021-02-15T10_18_59_arena10.csv  Miguel  \n",
       "2   video_2021-02-15T10_18_59_arena16.csv  Miguel  \n",
       "3    video_2021-02-15T10_18_59_arena6.csv  Miguel  \n",
       "4    video_2021-02-15T10_18_59_arena8.csv  Miguel  \n",
       "..                                    ...     ...  \n",
       "88   video_2021-02-19T10_46_46_arena3.csv  Sophie  \n",
       "89   video_2021-02-19T10_46_46_arena6.csv  Sophie  \n",
       "90   video_2021-02-19T10_46_46_arena9.csv  Sophie  \n",
       "91   video_2021-02-19T11_33_52_arena5.csv  Sophie  \n",
       "92   video_2021-02-19T11_33_52_arena6.csv  Sophie  \n",
       "\n",
       "[91 rows x 10 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "corrected_ratio_frames = pd.DataFrame()\n",
    "\n",
    "for condition in condition_order:\n",
    "\n",
    "    print('\\n\\t', condition, '\\n')\n",
    "\n",
    "    try:\n",
    "        dataset = aggression_df.query('condition==\"' + condition + '\"')['ratio_frames']\n",
    "\n",
    "        outlier_positions = helpers.check_outliers(dataset)\n",
    "        print(outlier_positions)\n",
    "\n",
    "        fresh_dataset = pd.DataFrame(helpers.remove_outliers(dataset, indices=outlier_positions))\n",
    "        fresh_dataset['condition'] = condition\n",
    "\n",
    "        corrected_ratio_frames = pd.concat([corrected_ratio_frames, fresh_dataset], axis=0)\n",
    "        \n",
    "    except ValueError as error:\n",
    "        print(error)\n",
    "\n",
    "aggression_df = aggression_df.loc[corrected_ratio_frames.index]\n",
    "aggression_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Aggression Bouts / Min."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>condition</th>\n",
       "      <th>ratio_bouts</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>gal4_control</td>\n",
       "      <td>1.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>gal4_control</td>\n",
       "      <td>0.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>gal4_control</td>\n",
       "      <td>2.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>gal4_control</td>\n",
       "      <td>1.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>gal4_control</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>test</td>\n",
       "      <td>1.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>test</td>\n",
       "      <td>2.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>test</td>\n",
       "      <td>1.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>test</td>\n",
       "      <td>1.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>test</td>\n",
       "      <td>1.8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>91 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       condition  ratio_bouts\n",
       "0   gal4_control          1.2\n",
       "1   gal4_control          0.8\n",
       "2   gal4_control          2.4\n",
       "3   gal4_control          1.4\n",
       "4   gal4_control          1.0\n",
       "..           ...          ...\n",
       "88          test          1.2\n",
       "89          test          2.4\n",
       "90          test          1.2\n",
       "91          test          1.8\n",
       "92          test          1.8\n",
       "\n",
       "[91 rows x 2 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_bouts_df = aggression_df.copy()[['condition', 'ratio_bouts']]\n",
    "ratio_bouts_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Statistics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\t gal4_control \n",
      "\n",
      "Shapiro's Test: group 1 IS normally distributed.\n",
      "D'Agostino's Test: group 1 IS normally distributed.\n",
      "Shapiro's Test: group 2 IS normally distributed.\n",
      "D'Agostino's Test: group 2 IS normally distributed.\n",
      "Bartlett's Test for normally distribted samples:\n",
      "  p-value = 0.713235\n",
      "  All groups were sampled from populations with IDENTICAL variances.\n",
      "\n",
      "Independent measures (two sample) t-test p-value: 0.0009291048999334584 \n",
      "\n",
      "\n",
      "\t uas_control \n",
      "\n",
      "Shapiro's Test: group 1 IS normally distributed.\n",
      "D'Agostino's Test: group 1 IS normally distributed.\n",
      "Shapiro's Test: group 2 IS normally distributed.\n",
      "D'Agostino's Test: group 2 IS normally distributed.\n",
      "Bartlett's Test for normally distribted samples:\n",
      "  p-value = 0.475703\n",
      "  All groups were sampled from populations with IDENTICAL variances.\n",
      "\n",
      "Independent measures (two sample) t-test p-value: 0.27213648202766577 \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'gal4_control': 0.0009291048999334584, 'uas_control': 0.27213648202766577}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_bouts_pvalues = {}\n",
    "\n",
    "test = ratio_bouts_df.query('condition==\"test\"')['ratio_bouts']\n",
    "\n",
    "for condition in condition_order[:-1]:\n",
    "        \n",
    "    print('\\n\\t', condition, '\\n')\n",
    "\n",
    "    try:\n",
    "        control = ratio_bouts_df.query('condition==\"' + condition + '\"')['ratio_bouts']\n",
    "\n",
    "        temp_values = {'control': control, 'test': test}\n",
    "\n",
    "        pvalue_condition = helpers.run_statistics(temp_values)\n",
    "\n",
    "        ratio_bouts_pvalues[condition] = pvalue_condition\n",
    "        \n",
    "    except ValueError as error:\n",
    "        print(error)\n",
    "    \n",
    "ratio_bouts_pvalues"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Bonferroni Correction\n",
      "---------------------\n",
      "\n",
      "\tOriginal Values:\n",
      " {'gal4_control': 0.0009291048999334584, 'uas_control': 0.27213648202766577}\n",
      "\n",
      "\tCorrected Values:\n",
      " {'gal4_control': 0.0018582097998669168, 'uas_control': 0.5442729640553315} \n",
      "\n"
     ]
    }
   ],
   "source": [
    "# Bonferroni corretction for multiple comparisons.\n",
    "title = 'Bonferroni Correction'\n",
    "print(title)\n",
    "print('-'*len(title))\n",
    "\n",
    "# Show uncorrected values.\n",
    "print('\\n\\tOriginal Values:\\n', ratio_bouts_pvalues)\n",
    "\n",
    "# Apply the bonferroni correction for multiple comparisons.\n",
    "ratio_bouts_multi_comp_correction = multipletests(pvals=list(ratio_bouts_pvalues.values()), alpha=0.05, method='bonferroni')[1]\n",
    "\n",
    "# Transform the correction results into a dictionary.\n",
    "corrected_ratio_bouts_pvalues = dict(zip(list(ratio_bouts_pvalues.keys()), ratio_bouts_multi_comp_correction))\n",
    "\n",
    "# Show corrected values.\n",
    "print('\\n\\tCorrected Values:\\n', corrected_ratio_bouts_pvalues, '\\n')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Effect Size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "gal4_control\n",
      "Small Effect: -0.27272727272727276 \n",
      "\n",
      "uas_control\n",
      "Vestigial Effect: 0.0 \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'gal4_control': -0.27272727272727276, 'uas_control': 0.0}"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_bouts_sizes = {}\n",
    "\n",
    "test = ratio_bouts_df.query('condition==\"test\"')['ratio_bouts']\n",
    "\n",
    "for condition in condition_order[:-1]:\n",
    "\n",
    "    print(condition)\n",
    "    \n",
    "    control = ratio_bouts_df.query('condition==\"' + condition + '\"')['ratio_bouts']\n",
    "\n",
    "    median_diff = helpers.get_effect_size(control, test, method='median_diff')\n",
    "    \n",
    "    ratio_bouts_sizes[condition] = median_diff\n",
    "    \n",
    "ratio_bouts_sizes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP4AAAEgCAYAAACU1c66AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nOydd1hT1xvHPwkbgkxRFAH3wi2Ke+9Zlap1W3FXa511onXUVa2ztbaOn3tv3AsV98StyJKN7J3k/v6gRlHEaAkJej/Pk+fhvsnN/eaGN+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KWl4dixY0/9XJ6m561eOPG7oM9DVJ+USNTxLSci1b1samoq3n33XQDA7NmzsW3bNtV2UVFRqKqqwtq1a/HCCy8gKioK8fHxnR5LKpXi4MGDWLp0KcrKyjRuY2lpqfHeurcJrl600o94zjxPXf2Ghgbq37+/WllVVRUNHDiQ8vLySCQSka2tLdnZ2ZGNjQ2JRCLKzs6moqIiSkxMVNtPoVCQiYkJERF5eHioXkQPurQKhYKIiD7//HPy8/OjlpYWIlLv0mrqXuuC0OqFr/gCY25uDicnJ+zfv19VtmPHDkyZMgUpKSmYP38+ysrKUFJSgvLycsydOxfbtm3D4MGDsXnzZpw4cUK138WLF+Hp6QkAkMlkqtdDffv2BQCsXLkS9+7d07ulotsTXL1o9WOF6SWFQkH+/v7k7u5Oo0aNorCwMKqurqaXXnqJ8vPz1ba9dOkSvfjii1RXV0c5OTk0fvx4Gj58ODk7O1NwcDCVlZVpPMajE1MUFhaSqakpnTx5Ui+v+ETCqhcewMOYAHFXnzEB4sRnTIA48RkTIE58xgSIE58xAeLEZ0yAOPEZEyBOfMYEiBOfMQHixGdMgP4P05usUuALpBgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 270x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Initialize figure.\n",
    "n_conditions = ratio_bouts_df['condition'].nunique()\n",
    "figure, axis = plt.subplots(figsize=(1.25*n_conditions, 4))\n",
    "\n",
    "# Draw the boxplot.\n",
    "sns.boxplot(x='condition',\n",
    "            y='ratio_bouts',\n",
    "            data=ratio_bouts_df,\n",
    "            order=condition_order,\n",
    "            width=0.6,\n",
    "            showfliers=False,\n",
    "            palette=['#b8f2e6', '#b8f2e6', '#0081a7'],\n",
    "            boxprops={'edgecolor': INK},\n",
    "            medianprops={'color': INK},\n",
    "            whiskerprops={'color': INK},\n",
    "            capprops={'color': INK}\n",
    "           )\n",
    "\n",
    "# Draw the swarmplot.\n",
    "sns.swarmplot(x='condition',\n",
    "              y='ratio_bouts',\n",
    "              data=ratio_bouts_df,\n",
    "              order=condition_order,\n",
    "              palette=['#b8f2e6', '#b8f2e6', '#0081a7'],\n",
    "              linewidth=0.75,\n",
    "              edgecolor=INK\n",
    "             )\n",
    "\n",
    "# Figure and axes formatting.\n",
    "axis.set_xlabel('')\n",
    "axis.set_xticklabels([''])\n",
    "axis.set_ylabel('# Bouts / Minute of Copulation')\n",
    "axis.set_ylim(0, 5)\n",
    "axis.set_yticks(np.arange(0, 5+1, 1))\n",
    "axis.set_yticklabels([round(label, 1) for label in axis.get_yticks()])\n",
    "\n",
    "# Table definition.\n",
    "row1 = [str(ratio_bouts_df.query('condition==\"'+condition+'\"').shape[0]) for condition in condition_order]\n",
    "row2 = ['OR67d-GAL4;\\n+', '+;\\nUAS-Kir', 'OR67d-GAL4;\\nUAS-Kir']\n",
    "cell_text = np.array([row1, row2])\n",
    "\n",
    "row_labels = ['n =', '']\n",
    "summary_table = axis.table(cellText= cell_text,\n",
    "                           cellLoc='center',\n",
    "                           rowLabels=row_labels,\n",
    "                           rowLoc='center',\n",
    "                           colLoc='center'\n",
    "                          )\n",
    "\n",
    "summary_table.auto_set_font_size(False)\n",
    "summary_table.set_fontsize(11)\n",
    "\n",
    "properties = summary_table.properties()\n",
    "table_cells = properties['children']\n",
    "for cell in table_cells:\n",
    "    cell.set_height(0.12)\n",
    "    cell.set_alpha(0)\n",
    "\n",
    "# Draw statistical results.\n",
    "for p, condition in enumerate(condition_order[:-1]):\n",
    "    sig_height = 6 if (corrected_ratio_bouts_pvalues.get(condition, 'NaN') == 'NaN') or (corrected_ratio_bouts_pvalues.get(condition, 'NaN') >= 0.05) else 2\n",
    "    helpers.plot_stattest_result(ax=axis,\n",
    "                                 x1=p,\n",
    "                                 x2=p,\n",
    "                                 p_value=corrected_ratio_bouts_pvalues.get(condition, 'NaN'),\n",
    "                                 y=4.5,\n",
    "                                 ticksize=0,\n",
    "                                 xytext=(0,sig_height),\n",
    "                                 fontsize=13,\n",
    "                                 color=INK,\n",
    "                                 connector_color=INK\n",
    "                                )\n",
    "\n",
    "# Saving parameters.\n",
    "filename = 'nbouts_aggression_normalized_5mins_Or67d'\n",
    "plt.savefig(os.path.join(savepath, filename))\n",
    "\n",
    "plt.show()\n",
    "plt.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
